package homework15;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
@SuppressWarnings({"all"})

public class JInternalFrameDemo implements ActionListener{
    private static JInternalFrame1 internalFrame;
    Container contentPane = this.getContentPane();

    private Container getContentPane() {
        return getContentPane();
    }

    public JInternalFrameDemo(){
        super();
        contentPane.setLayout(new BorderLayout());
        JButton button = new JButton("创建一个子窗体");
        button.addActionListener(this);
        contentPane.add(button, BorderLayout.SOUTH);
        this.setSize(new Dimension(300, 300));
        this.setVisible(true);
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }

    public void addWindowListener(WindowAdapter windowAdapter) {
        System.out.println("主窗口");
    }

    public void setVisible(boolean b) {
        System.out.println("");
    }

    public void setSize(Dimension dimension) {
    }

    public void actionPerformed(ActionEvent e) {
        internalFrame = JInternalFrame1.getJInternalFrame1("子窗体"
                , true, true, true, true);
        internalFrame.setSize(new Dimension(200, 200));
        internalFrame.setVisible(true);
        JDesktopPane desktopPane = new JDesktopPane();
        contentPane.add(desktopPane);
        desktopPane.add(internalFrame);
        try {
            internalFrame.setSelected(true);
        } catch (java.beans.PropertyVetoException ex) {
            System.out.println("Exception while selecting");
        }
    }
}
